package com.example.agrigreennewssys.utils;

import lombok.Data;

/**
 * @author 光的代言人
 */
@Data
public class Result {


    /**
     * 异常码
     */
    private Integer code;
    /**
     * 异常信息
     */
    private String msg;
    /**
     * 返回数据
     */
    private Object data;

    //实际应用中code不同的编号代表不同的意思，需要后台程序员定义
    public Result() {
        this.code = 200;
        this.msg = "操作成功";


    }
    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static Result success() {
        return new Result();
    }
    public static Result success(Object data) {
        Result result = new Result();
        result.setData(data);
        return result;
    }

    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static void main(String[] args) {

    }




}